const PARAM_ERROR_CODE = -1,
  SUCCESS_CODE = 0,
  FAIL_CODE = 1,
  NORMAL_ERROR_CODE = 1,
  SESSION_EXPIRED_CODE = 99,
  ACCESS_TOKEN_INVALID_CODE = 99;

function successResult(data) {
  if (data) {
    return {"success": true, "errCode": SUCCESS_CODE, "msg": "success", data: data};
  } else {
    return {"success": true, "errCode": SUCCESS_CODE, "msg": "success"};
  }
}

function paramsError() {
  return {"success": false, "errCode": PARAM_ERROR_CODE, "msg": "参数错误"};
}

function sessionInvalid() {
  return {"success": false, "errCode": SESSION_EXPIRED_CODE, "msg": "invalid"};
}

function failError(){
  return {"success": false, "errCode": FAIL_CODE, "msg": "失败"};
}

module.exports={
  successResult,paramsError,sessionInvalid,failError
}
